//
//  StatusForwardCell.swift
//  SynWeibo
//
//  Created by 沈艳男 on 15/9/13.
//  Copyright © 2015年 沈艳男. All rights reserved.
//

import UIKit

class StatusForwardCell: StatusCell {
    
    override var statusViewModel: StatusViewModel? {
        didSet {
            forwardLabel.text = statusViewModel?.forwardText
        }
    }
    
    // 设置UI
    override func setUI() {
        super.setUI()
        // 1.添加控件
        // 把按钮插入到视图后面
        contentView.insertSubview(backButton, belowSubview: pictureView)
        // 把文字插入到按钮上面
        contentView.insertSubview(forwardLabel, aboveSubview: backButton)
        
        // 2.设置自定布局
        backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: -StatusCellMargin, y: StatusCellMargin))
        backButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
        forwardLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil, offset: CGPoint(x: StatusCellMargin, y: StatusCellMargin))
        
        // 3.配图视图布局
        let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLabel, size: CGSize(width: StatusPictureMaxWidth, height: StatusPictureMaxWidth), offset: CGPoint(x: 0, y: StatusPictureItemMargin))
        // 记录配图试图的约束
        // 从自动布局返回的数组中取出配图的高度
        pictureViewWidthCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        pictureViewHeightCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        pictureViewTopCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)

    }
    // 懒加载按钮
    private lazy var backButton: UIButton = {
        let button = UIButton()
        button.backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        return button
    }()
    
    /// 设置转发文字
    private lazy var forwardLabel: UILabel = UILabel(title: "转发微博***********************", color: UIColor.darkGrayColor(), fontSize: 14, layoutWidth: UIScreen.mainScreen().bounds.width - StatusCellMargin)
    

}
